package com.itcast.donkey.application;

import android.app.Application;

import org.xutils.DbManager;
import org.xutils.x;


/**
 * Created by lanouhn on 16/8/31.
 */
public class MyApplication extends Application {

    public DbManager.DaoConfig config;
    public DbManager db;

    public DbManager.DaoConfig getConfig() {
        return config;
    }

    @Override
    public void onCreate() {
        super.onCreate();
        x.Ext.init(this);//初始化

        x.Ext.setDebug(true);//是否输出Debug日志

        config = new DbManager.DaoConfig();
        config.setDbName("dbAccount").setDbVersion(1);
        config.setDbUpgradeListener(new DbManager.DbUpgradeListener() {
            @Override
            public void onUpgrade(DbManager db, int oldVersion, int newVersion) {

            }
        }).setDbOpenListener(new DbManager.DbOpenListener() {
            @Override
            public void onDbOpened(DbManager db) {
                db.getDatabase().enableWriteAheadLogging();
            }
        });
        config.setAllowTransaction(true);
        db = x.getDb(config);
    }
}
